import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TopNavigator extends StatelessWidget {
  final List categories;
  const TopNavigator({this.categories});

  @override
  Widget build(BuildContext context) {
    if (categories.length > 10) {
      categories.removeRange(10, categories.length);
    }

    return Container(
      height: ScreenUtil().setWidth(320),
      padding: EdgeInsets.all(3.0),
      child: GridView.count(
        crossAxisCount: 5,
        padding: EdgeInsets.all(4.0),
        children: categories.map((item) {
          return _buildNavigatorItem(context, item);
        }).toList(),
      ),
    );
  }

  Widget _buildNavigatorItem(BuildContext context, Map item) {
    return InkWell(
      onTap: () {
        print("点击了...");
      },
      child: Column(
        children: <Widget>[
          Image.network(item['image'], width: ScreenUtil().setWidth(95)),
          Text(item['mallCategoryName'], style: TextStyle(fontSize: 12))
        ],
      ),
    );
  }
}
